
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>修改出差记录</title>

<!-- BootStrap -->
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
	href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

<!-- easy UI -->
<link rel="stylesheet" type="text/css"
	href="../themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../themes/color.css">
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		//获取当前年月日
		$.ajax({
			url:'../getCurrentYearAndTime',
			type:'post',
			dataType:"json",
			success:function(date){
				$('#year').append("<option selected='selected'>"+date.currentyear+"</option>")
				$('#year').append("<option>"+date.lastyear+"</option>")
				$('#year').append("<option>"+date.lasttwoyear+"</option>")
				$("option[value="+date.currentmonth+"]").attr("selected", "selected");
			}
		});
		//下拉框获取部门
		$.ajax({				
			url: "../selectDepartment",
			type:'post',
			dataType:"json",
			async:false,
			success:function(r){
				for (var i = 0; i < r.depts.length; i++) {
					$("#dept").append("<option>"+r.depts[i].dep_name+"</option>");
				}
			}
		});
		//提交点击事件
		$("#btn").click( function() {
			var dep_name = $('#dept option:selected').text()
			var year = $('#year option:selected').text()
			var month = $('#month option:selected').text()
			$('#dg').datagrid('load',{
				dep_name:dep_name,
				year:year,
				month:month
			});
		});
		//窗口的属性
		$('#win').window({    
		    width:600,    
		    height:400,    
		    modal:true,
		    title:'修改记录',
		});
		//关闭窗口
		$('#win').window('close');
		//数据表格
		$('#dg').datagrid({    
		    url:'../selectBtravel',    
		    columns:[[
				{field:'checkbox',checkbox:true,width:100},
				{field:'att_id',title:'记录表id',width:200,hidden:true},
				{field:'uid',title:'用户id',width:200,hidden:true},
				{field:'uname',title:'用户姓名',width:200,resizable:true},    
				{field:'state',title:'状态',width:200,resizable:true},
				{field:'time',title:'时长（：天）',width:200,resizable:true},  
				{field:'date',title:'日期',width:200,resizable:true},  
				{field:'remark',title:'备注',width:270,resizable:true},  
		    ]],
		    pagination:true,
		    striped:true,
		    pageSize:10,
		    pageList:[10,15,20],
		    width:'1070px',
		    
		    toolbar: [{
				iconCls: 'icon-edit',
				text:'修改出差记录',
				handler: function(){
					var attends =  $('#dg').datagrid('getSelections');
					if (attends.length == 1) {
						$.messager.confirm('确认修改', '确认修改吗？', function(r){
		    				if (r){
								$('#win').window('open');
		    					$('#att_id').hide();
		    					var msg = eval(attends[0]);
		    					$('#ff').form('load',msg);
		    					$('#ff').form({    
		    					    url:'../updateBtravel',    
		    					    success:function(data){
		    					    	var d = eval("("+data+")")
		    					    	if (d.flag) {
		    					    		$('#win').window('close');
		    					    		$('#dg').datagrid('reload'); 
		    					    		$('#dg').datagrid('selectAll'); 
										}
		    					    }
		    					});
    		    			}
    		    		})
					}
				}
		    }]
		});
	});
	
</script>
<body>
	<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
		<div class="container">
			<p class="navbar-text"><h1>修改出差记录:</h1></p>
		</div>
	</nav>
	<div class="container-fluid">
		<div class="row" style="margin-top: 50px;">
			<div class="col-md-12">
				<div class="page-header">
					<h1>条件选择<small>查询修改...&nbsp;<span class="glyphicon glyphicon-hand-right"></span></small></h1>
					<div style="margin-left: 341px;margin-top: -43px;">
						<select id="dept" name="sel">
							<option value="0">部门</option>
						</select>
						<select id="year" name="sel">
						  <option value="0">年份</option>
						</select>
						<select id="month" name="sel">
						  <option value="0">月份</option>
						  <option value="1">01</option>
						  <option value="2">02</option>
						  <option value="3">03</option>
						  <option value="4">04</option>
						  <option value="5">05</option>
						  <option value="6">06</option>
						  <option value="7">07</option>
						  <option value="8">08</option>
						  <option value="9">09</option>
						  <option value="10">10</option>
						  <option value="11">11</option>
						  <option value="12">12</option>
						</select>
						<button id="btn" type="button" class="btn btn-info">提交</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	<div class="container-fluid">
			<div class="row">
				<div class="col-md-1"></div>
				<div class="col-md-11">
					<table id="dg"></table>
				</div>
			</div>
	</div>	
	
	<div id="win">
		<form id="ff">
			<div id="att_id">
				<input class="easyui-textbox" name="att_id"
					data-options="prompt:'记录表ID'" style="width: 300px">
			</div>
			<div style="visibility: hidden;">
				<input class="easyui-textbox" name="uid" id="uid"
					data-options="prompt:'用户ID'" style="width: 300px">
			</div>
			<input
				class="easyui-textbox" name="uname" id="uname"
				data-options="prompt:'用户姓名'" style="width: 300px"> <input
				class="easyui-textbox" name="state" id="state"
				data-options="prompt:'状态'" style="width: 300px"> <input
				class="easyui-textbox" name="time" id="time"
				data-options="prompt:'时长'" style="width: 300px"> <input
				class="easyui-textbox" name="date" id="date"
				data-options="prompt:'日期'" style="width: 300px"> <input
				class="easyui-textbox" name="remark" id="remark"
				data-options="prompt:'备注'" style="width: 300px">
			<button class="easyui-linkbutton" type="submit">提交</button>
		</form>
	</div>
</body>
</html>